<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" type="shortcut icon" th:href="@{/img/favicon.ico}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/global.css}"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
    <title>Echo - 个人主页</title>
</head>
<body>
<div class="nk-container">
    <!-- 头部 -->
    <header class="bg-dark sticky-top" th:replace="index::header"></header>

    <!-- 内容 -->
    <div class="main">
        <div class="container">
            <!-- 选项 -->
            <div class="position-relative">
                <ul class="nav nav-tabs" th:fragment="profiletab">
                    <li class="nav-item">
                        <a th:class="|nav-link ${tab=='profile' ? 'active' : ''}|"
                           th:href="@{/follower/info(entityId=${userManager.id})}">个人信息</a>
                    </li>
                    <li class="nav-item" th:if="${loginUser.userId == userManager.id}">
                        <a th:class="|nav-link ${tab=='mypost' ? 'active' : ''}|"
                           th:href="@{/user/discuss(entityId=${userManager.id})}">我的帖子</a>
                    </li>
                    <li class="nav-item" th:if="${loginUser.userId != userManager.id}">
                        <a th:class="|nav-link ${tab=='mypost' ? 'active' : ''}|"
                           th:href="@{/user/discuss(entityId=${userManager.id})}">他的帖子</a>
                    </li>
                    <li class="nav-item" th:if="${loginUser.userId == userManager.id}">
                        <a th:class="|nav-link ${tab=='myreply' ? 'active' : ''}|"
                           th:href="@{/user/comment(entityId=${userManager.id})}">我的回复</a>
                    </li>
                    <li class="nav-item" th:if="${loginUser.userId != userManager.id}">
                        <a th:class="|nav-link ${tab=='myreply' ? 'active' : ''}|"
                           th:href="@{/user/comment(entityId=${userManager.id})}">他的回复</a>
                    </li>
                </ul>
            </div>
            <!-- 个人信息 -->
            <div class="media mt-5">
                <img th:src="${userManager.headerUrl}" class="align-self-start mr-4 rounded-circle" alt="用户头像"
                     style="width:50px;">
                <div class="media-body">
                    <form id="user-follower-form" onsubmit="return followerForm()" th:action="@{/follower/click}"
                          method="post">
                        <h5 class="mt-0 text-warning">
                            <span th:utext="${userManager.username}"></span>
                            <input type="hidden" name="entityId" id="entityId" th:value="${userManager.id}">
                            <input type="hidden" name="userId" id="userId" th:value="${loginUser.userId}">
                            <button type="submit"
                                    th:class="|btn ${hasFollowed ? 'btn-secondary' : 'btn-info'} btn-sm float-right mr-5 follow-btn|"
                                    th:text="${hasFollowed ? '已关注' : '关注TA'}"
                                    th:if="${userManager!=null && userManager.id != loginUser.userId}">
                            </button>

                        </h5>
                    </form>
                    <div class="text-muted mt-3">
                        <span>注册于 <i class="text-muted"
                                        th:text="${#dates.format(userManager.createTime, 'yyyy-MM-dd HH:mm:ss')}"></i></span>
                    </div>
                    <div class="text-muted mt-3 mb-5">
                        <a class="text-primary"
                           th:href="@{/follower/findFollowerListByUserId(entityId=${userManager.id})}"
                           style="margin-right: 6px">
                            <button type="button" class="btn btn-secondary">
                                关注了 <span class="badge badge-info" th:text="${followerCount}"></span> 人
                            </button>
                        </a>
                        <a class="text-primary" th:href="@{/follower/findFansListByUserId(entityId=${userManager.id})}"
                           style="margin-right: 6px">
                            <button type="button" class="btn btn-secondary">
                                关注者 <span class="badge badge-info" th:text="${fansCount}"></span> 人
                            </button>
                        </a>

                        <button type="button" class="btn btn-secondary">
                            获得了 <span class="badge badge-light" th:text="${userLikeCount}"></span> 个赞
                        </button>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 尾部 -->
    <footer class="bg-dark" th:replace="index::footer"></footer>
</div>

<script th:src="@{/js/jquery-3.1.0.min.js}"></script>
<script th:src="@{/js/popper.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/global.js}"></script>
<script th:src="@{/js/httpUtils.js}"></script>
<script th:src="@{/js/profile.js}"></script>
<script type="text/javascript">
    function followerForm() {
        submitForm("blog/follower/click", $("#user-follower-form"), function (result) {
            location.reload();
        })
        return false
    }
</script>
</body>
</html>
